package com.wsoft.controller;

import com.wsoft.constant.RedisKeyConstant;
import com.wsoft.response.ResponseResult;
import com.wsoft.service.IDictCacheService;
import com.wsoft.vo.DictCacheVO;
import com.wsoft.vo.DictDataCacheVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Zhang gukai
 * @Date 2024/9/11 9:23
 */
@RestController
@Tag(name = "公共数据字典")
@RequestMapping("/pub/dict")
public class DictCacheController {

    @Resource
    private IDictCacheService dictCacheService;
    @Operation(summary = "通过父级字典名称查询其下子项字典",description = "通过父级字典名称查询其下子项字典")
    @ApiResponse(responseCode = "200", description = "OK")
    @GetMapping("/getDataListByCode")
    public ResponseResult getDataListByCode(@RequestParam("code") String code){
        List<DictDataCacheVO> list = dictCacheService.getDictByCode(code);
        return ResponseResult.success(list);
    }

    @Operation(summary = "获取全部字典",description = "获取全部字典")
    @ApiResponse(responseCode = "200", description = "OK")
    @GetMapping("/getAllDict")
    public ResponseResult getAllDict(){
        List<DictCacheVO> list = dictCacheService.selectAll();
        return ResponseResult.success(list);
    }
}
